Current File : //usr/lib/python3/dist-packages/twisted/python/test/__pycache__/test_release.cpython-312.pyc
�

Ϫ�f�@����dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZddlmZddlmZej2dk7rdZnd	Zd
ej6dd�Zd
ej6dd�ZdZGd�de�Zd�Zd�Z d�Z!Gd�d�Z"Gd�de�Z#Gd�de�Z$Gd�de�Z%Gd�de"�Z&Gd�de&e�Z'Gd �d!e�Z(Gd"�d#e�Z)y)$z�
Tests for L{twisted.python.release} and L{twisted.python._release}.

All of these tests are skipped on platforms other than Linux, as the release is
only ever performed on Linux.
�N)�Version)�release)	�
GitCommand�IVCSCommand�NotWorkingDirectory�Project�
filePathDelta�findTwistedProjects�getRepositoryCommand�
replaceInFile�
runCommand)�FilePath)�TestCase�win32z*Release toolchain only supported on POSIX.zpre-commit-ci-update-config�PATH)�GITHUB_HEAD_REFrz1234-some-branch-name�Not relevant within Debian.c��eZdZdZd�Zy)�ExternalTempdirTestCasez�
    A test case which has mkdir make directories outside of the usual spot, so
    that Git commands don't interfere with the Twisted checkout.
    c��tjtj���}|jtj
|�|S)z)
        Make our own directory.
        )�dir)�tempfile�mkdtemp�
gettempdir�
addCleanup�shutil�rmtree)�self�newDirs  �B/usr/lib/python3/dist-packages/twisted/python/test/test_release.py�mktempzExternalTempdirTestCase.mktemp;s4���!�!�h�&9�&9�&;�<������
�
�v�.��
�N)�__name__�
__module__�__qualname__�__doc__r!�r"r rr5s���
r"rc���tddd|jd�jd�jddg�tddd|jd�jd�jddg�y	)
z�
    Set some config in the repo that Git requires to make commits. This isn't
    needed in real usage, just for tests.

    @param path: The path to the Git repository.
    @type path: L{FilePath}
    �git�configz--filez.gitz	user.namez	"someone"z
user.emailz"someone@someplace.com"N)r
�child�path�r,s r �
_gitConfigr.Dsx�������J�J�v��$�$�X�.�3�3���
	
�	������J�J�v��$�$�X�.�3�3��%�
	
�	r"c�J�tdd|jg�t|�y)z�
    Run a git init, and set some config that git requires. This isn't needed in
    real usage.

    @param path: The path to where the Git repo will be created.
    @type path: L{FilePath}
    r)�initN)r
r,r.r-s r �_gitInitr1bs����v�t�y�y�)�*��t�r"c�6�djt|i|���S)z�
    A convenience for generating _version.py data.

    @param args: Arguments to pass to L{Version}.
    @param kwargs: Keyword arguments to pass to L{Version}.
    z0from incremental import Version
__version__={!r})�formatr)�args�kwargss  r �
genVersionr6ns$��?�E�E��� �� ��r"c��eZdZdZd�Zd�Zy)�StructureAssertingMixinz�
    A mixin for L{TestCase} subclasses which provides some methods for
    asserting the structure and contents of directories and files on the
    filesystem.
    c�&�|D]�}|j|�}t||t�r&|j�|j	|||��M|j||j
dtj�j����y)a#
        Create a set of directories and files given a dict defining their
        structure.

        @param root: The directory in which to create the structure.  It must
            already exist.
        @type root: L{FilePath}

        @param dirDict: The dict defining the structure. Keys should be strings
            naming files, values should be strings describing file contents OR
            dicts describing subdirectories.  All files are written in binary
            mode.  Any string values are assumed to describe text files and
            will have their newlines replaced with the platform-native newline
            convention.  For example::

                {"foofile": "foocontents",
                 "bardir": {"barfile": "bar
contents"}}
        @type dirDict: C{dict}
        �
N)
r+�
isinstance�dict�createDirectory�createStructure�
setContent�replace�os�linesep�encode)r�root�dirDict�xr+s     r r>z'StructureAssertingMixin.createStructure�s|��(�	P�A��J�J�q�M�E��'�!�*�d�+��%�%�'��$�$�U�G�A�J�7�� � ����!3�!3�D�"�*�*�!E�!L�!L�!N�O�
	Pr"c��|j�D�cgc]}|j���}}|j�D]�\}}|j|�}t	|�r|j||��n�t
|t�r@|j|j�|j�d��|j||�nN|j�j�jtjd�}|j!||�|j#|���|r"|j%d|j�d|���yycc}w)a�
        Assert that a directory is equivalent to one described by a dict.

        @param root: The filesystem directory to compare.
        @type root: L{FilePath}
        @param dirDict: The dict that should describe the contents of the
            directory. It should be the same structure as the C{dirDict}
            parameter to L{createStructure}.
        @type dirDict: C{dict}
        z is not a dir!r:zThere were extra children in z: N)�children�basename�itemsr+�callable�
assertTruer;r<�isdirr,�assertStructure�
getContent�decoder@rArB�assertEqual�remove�fail)	rrDrE�eachrH�pathSegment�expectationr+�actuals	         r rNz'StructureAssertingMixin.assertStructure�s��15�
�
��@��D�M�M�O�@��@�(/�
�
��
	)�$�K���J�J�{�+�E���$�����E� 2�3��K��.�������
�%�*�*��^�/L�M��$�$�U�K�8��)�)�+�2�2�4�<�<�R�Z�Z��N��� � ���5��O�O�K�(�
	)���I�I�5�d�i�i�[��8�*�M�N���As�EN)r#r$r%r&r>rNr'r"r r8r8zs���P�8Or"r8c�6�eZdZdZd�Zd	d�Zd�Zd�Zd�Zd�Z	y)
�ProjectTestsz=
    There is a first-class representation of a project.
    c�@�|jt|�t|��t|tjd���}t|tjd���}t||�D]+\}}|j|j|j��-y)zA
        Assert that two lists of L{Project}s are equal.
        �	directory)�keyN)rQ�len�sorted�operator�
attrgetter�zipr[)r�observedProjects�expectedProjects�observed�expecteds     r �assertProjectsEqualz ProjectTests.assertProjectsEqual�s���	
����-�.��4D�0E�F�!��(�"5�"5�k�"B�
��"��(�"5�"5�k�"B�
��#&�&6�8H�"I�	E��H�h����X�/�/��1C�1C�D�	Er"Nc���|�t|j��}|djd�}|}|D]S}|j|�}|j	�s|j�|jd�j
d��U|jd�j�|jd�j
t|�j��t|�S)a(
        Make a Twisted-style project in the given base directory.

        @param baseDirectory: The directory to create files in
            (as a L{FilePath).
        @param version: The version information for the project.
        @return: L{Project} pointing to the created project.
        r�.z__init__.pyr"�
newsfragments�_version.py)
rr!�splitr+�existsr=r?r6rCr)r�version�
baseDirectory�segmentsr[�segments      r �makeProjectzProjectTests.makeProject�s���� �$�T�[�[�]�3�M��1�:�#�#�C�(��!�	��	;�G�!����0�I��#�#�%��)�)�+��O�O�M�*�5�5�c�:�		;�
	����(�8�8�:����
�&�1�1�*�g�2F�2M�2M�2O�P��y�!�!r"c�j�t|j��}|D]}|j||��|S)z�
        Create a series of projects underneath a temporary base directory.

        @return: A L{FilePath} for the base directory.
        )rr!rq)r�versionsrnrms    r �makeProjectszProjectTests.makeProjects�s9��!�����/�
��	5�G����W�m�4�	5��r"c�v�d}|j|�}|j|j�t|��y)z5
        Project objects know their version.
        )�twisted��rN)rqrQ�
getVersionr)rrm�projects   r �test_getVersionzProjectTests.test_getVersion�s7��'���"�"�7�+������+�+�-�w��/@�Ar"c�|�ttd��}|jt|�d|jz�y)zH
        The representation of a Project is Project(directory).
        �barzProject(%r)N)rrrQ�reprr[)r�foos  r �	test_reprzProjectTests.test_repr�s/���h�u�o�&������c��M�S�]�]�$C�Dr"c	���|jdd�}t|�}|j|t|j	d��t|j	d�j	d��g�y)z�
        findTwistedStyleProjects finds all projects underneath a particular
        directory. A 'project' is defined by the existence of a 'newsfragments'
        directory and is returned as a Project object.
        )rrw�r)zfoo.barr��rr}N)rtr
rfrr+)rrn�projectss   r �test_findTwistedStyleProjectsz*ProjectTests.test_findTwistedStyleProjects�si���)�)�*:�<P�Q�
�&�}�5��� � ���
�+�+�E�2�3��
�+�+�E�2�8�8��?�@�
�	
r"�N)
r#r$r%r&rfrqrtr{r�r�r'r"r rYrY�s(���E�"�,	�B�E�
r"rYc��eZdZdZd�Zd�Zy)�UtilityTestsz<
    Tests for various utility functions for releasing.
    c���tj�}d�}|jttj
|�|j
|tj��y)z�
        Test that the runChdirSafe is actually safe, i.e., it still
        changes back to the original directory even if an error is
        raised.
        c�b�tjd�tjd�ddzy)N�	releaseChrxr)rA�mkdir�chdirr'r"r �
chAndBreakz+UtilityTests.test_chdir.<locals>.chAndBreaks!���H�H�[�!��H�H�[�!�
��Fr"N)rA�getcwd�assertRaises�ZeroDivisionErrorr�runChdirSaferQ)r�cwdr�s   r �
test_chdirzUtilityTests.test_chdirsE���i�i�k��	�
	
���+�W�-A�-A�:�N�����b�i�i�k�*r"c���d}tdd�5}|j|�ddd�|jdd�}tdddi�td�5}|j	|j�|�ddd�|jdd�}tdddi�td�5}|j	|j�|�ddd�y#1swY��xYw#1swY�jxYw#1swYyxYw)z�
        L{replaceInFile} replaces data in a file based on a dict. A key from
        the dict that is found in the file is replaced with the corresponding
        value.
        zfoo
hey hey $VER
bar
zrelease.replace�wNz$VERz2.0.0z3.0.0)�open�writer@rrQ�read)r�content�outfre�fs     r �test_replaceInFilezUtilityTests.test_replaceInFile!s���-��
�#�S�
)�	 �T��J�J�w��	 ��?�?�6�7�3���'�&�'�):�;�
�#�
$�	1�����Q�V�V�X�x�0�	1��#�#�G�W�5���'�'�7�);�<�
�#�
$�	1�����Q�V�V�X�x�0�	1�	1�	 �	 ��
	1�	1��
	1�	1�s#�C�!C�(!C*�C�C'�*C3N)r#r$r%r&r�r�r'r"r r�r�s���+� 1r"r�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�FilePathDeltaTestsz%
    Tests for L{filePathDelta}.
    c�b�|jttd�td��dg�y)zU
        L{filePathDelta} can create a simple relative path to a child path.
        �/foo/barz/foo/bar/baz�bazN�rQr	r�rs r �test_filePathDeltaSubdirz+FilePathDeltaTests.test_filePathDeltaSubdir;s*��	
����(�:�.���0H�I�E�7�	
r"c�d�|jttd�td��ddg�y)ze
        L{filePathDelta} can traverse upwards to create relative paths to
        siblings.
        r�z/foo/baz�..r�Nr�r�s r �test_filePathDeltaSiblingDirz/FilePathDeltaTests.test_filePathDeltaSiblingDirCs,��
	
����(�:�.���0D�E��e�}�	
r"c�d�|jttd�td��gd��y)zx
        L{filePathDelta} can create relative paths to totally unrelated paths
        for maximum portability.
        r�z	/baz/quux)r�r�r��quuxNr�r�s r �test_filePathNoCommonElementsz0FilePathDeltaTests.test_filePathNoCommonElementsLs)��
	
����(�:�.���0E�F�'�	
r"c�d�|jttd�td��gd��y)z�
        L{filePathDelta} doesn't take into account final elements when
        comparing 2 paths, but stops at the first difference.
        z/foo/bar/bar/spamz/foo/bar/baz/spam)r�r�r��spamNr�r�s r �$test_filePathDeltaSimilarEndElementsz7FilePathDeltaTests.test_filePathDeltaSimilarEndElementsVs+��
	
����(�#6�7��BU�9V�W�'�	
r"N)r#r$r%r&r�r�r�r�r'r"r r�r�6s���
�
�
�
r"r�c�>�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�CommandsTestMixinzF
    Test mixin for the VCS commands used by the release scripts.
    rc�@�t|j��|_yr�)rr!�tmpDirr�s r �setUpzCommandsTestMixin.setUphs���t�{�{�}�-��r"c��|j|j�}|j|jj	|��y)z�
        Calling the C{ensureIsWorkingDirectory} VCS command's method on a valid
        working directory doesn't produce any error.
        N)�makeRepositoryr��assertIsNone�
createCommand�ensureIsWorkingDirectory�r�reposDirs  r �1test_ensureIsWorkingDirectoryWithWorkingDirectoryzCCommandsTestMixin.test_ensureIsWorkingDirectoryWithWorkingDirectoryks7��
�&�&�t�{�{�3�����$�,�,�E�E�h�O�Pr"c�n�|jt|jj|j�y)z�
        Calling the C{ensureIsWorkingDirectory} VCS command's method on an
        invalid working directory raises a L{NotWorkingDirectory} exception.
        N)r�rr�r�r�r�s r �4test_ensureIsWorkingDirectoryWithNonWorkingDirectoryzFCommandsTestMixin.test_ensureIsWorkingDirectoryWithNonWorkingDirectoryss+��
	
�������7�7��K�K�	
r"c��|j|j�}|j|jj	|��y)z�
        Calling the C{isStatusClean} VCS command's method on a repository with
        no pending modifications returns C{True}.
        N)r�r�rLr��
isStatusCleanr�s  r �test_statusCleanz"CommandsTestMixin.test_statusClean~s5��
�&�&�t�{�{�3������*�*�8�8��B�Cr"c���|j|j�}|jd�jd�|j	|j
j
|��y)z�
        Calling the C{isStatusClean} VCS command's method on a repository with
        no pending modifications returns C{False}.
        �	some-file�	somethingN)r�r�r+r?�assertFalser�r�r�s  r �test_statusNotCleanz%CommandsTestMixin.test_statusNotClean�sN��
�&�&�t�{�{�3�����{�#�.�.�|�<�����+�+�9�9�(�C�Dr"c�v�|j|j�}|jd�}|jd�|j	|�|j|j
��|jj|�|jd�|j|j
�d�y)zr
        Calling the C{remove} VCS command's method remove the specified path
        from the directory.
        r�r�FzFile still existsN)r�r�r+r?�commitRepositoryrLrlr�rR�restatr�)rr��testFiles   r �test_removezCommandsTestMixin.test_remove�s���
�&�&�t�{�{�3���>�>�+�.�����L�)����h�'�������)�*����!�!�(�+������������*�,?�@r"c
�|�ddditdddd�dditdddd�d�d	�d
�}|j|j�}|j||�|j	|�t|j
��jd�}|jj||�|j||�y)
z�
        The C{exportTo} VCS command's method export the content of the
        repository as identical in a specified directory.
        zHi this is 1.0.0.�READMEzHi this is 1.0.0rvrxrztwisted.web)rirj)rirj�web)z
README.rstrv�exportN)r6r�r�r>r�rr!r+r��exportTorN)r�	structurer��	exportDirs    r �test_exportzCommandsTestMixin.test_export�s���.�"*�,>�!?�)�)�Q��1�=�&.�0B�%C�#-�m�Q��1�#E���

�	��&�&�t�{�{�3�����X�y�1����h�'��T�[�[�]�+�1�1�(�;�	����#�#�H�i�8����Y�	�2r"N)r#r$r%r&�skipr�r�r�r�r�r�r�r'r"r r�r�as5���)�D�.�Q�	
�D�E�
A�3r"r�c�$�eZdZdZdZeZd�Zd�Zy)�GitCommandTestz^
    Specific L{CommandsTestMixin} related to Git repositories through
    L{GitCommand}.
    rc��t|�|S)z�
        Create a Git repository in the specified path.

        @type root: L{FilePath}
        @params root: The directory to create the Git repository into.

        @return: The path to the repository just created.
        @rtype: L{FilePath}
        )r1)rrDs  r r�zGitCommandTest.makeRepository�s��	����r"c��tdd|jdgtj|jdz�z�tdd|jdddg�y)	z�
        Add and commit all the files from the Git repository specified.

        @type repository: L{FilePath}
        @params repository: The Git repository to commit into.
        r)z-C�addz/*�commitz-m�hopN)r
r,�glob)r�
repositorys  r r�zGitCommandTest.commitRepository�sO��	�
�D�*�/�/�5�1�D�I�I�j�o�o�PT�>T�4U�U�	
�	�E�4����(�D�%�H�Ir"N)	r#r$r%r&r�rr�r�r�r'r"r r�r��s���
)�D��M��
Jr"r�c�"�eZdZdZd�Zd�Zd�Zy)�RepositoryCommandDetectionTestz
    Test the L{getRepositoryCommand} to access the right set of VCS commands
    depending on the repository manipulated.
    c�@�t|j��|_yr�)rr!�reposr�s r r�z$RepositoryCommandDetectionTest.setUp�s���d�k�k�m�,��
r"c��t|j�t|j�}|j|t�y)zV
        L{getRepositoryCommand} from a Git repository returns L{GitCommand}.
        N)r1r�r�assertIsr)r�cmds  r �test_gitz'RepositoryCommandDetectionTest.test_git�s,��	�����"�4�:�:�.���
�
�c�:�&r"c�N�|jtt|j�y)z�
        L{getRepositoryCommand} from a directory which doesn't look like a Git
        repository produces a L{NotWorkingDirectory} exception.
        N)r�rrr�r�s r �test_unknownRepositoryz5RepositoryCommandDetectionTest.test_unknownRepository�s��
	
���-�/C�T�Z�Z�Pr"N)r#r$r%r&r�r�r�r'r"r r�r��s���
-�'�Qr"r�c��eZdZdZd�Zy)�VCSCommandInterfaceTestszF
    Test that the VCS command classes implement their interface.
    c�T�|jtjt��y)z:
        L{GitCommand} implements L{IVCSCommand}.
        N)rLr�
implementedByrr�s r r�z!VCSCommandInterfaceTests.test_git�s��	
����1�1�*�=�>r"N)r#r$r%r&r�r'r"r r�r��s���?r"r�)*r&r�r_rAr�sysr�incrementalr�twisted.pythonr�twisted.python._releaserrrrr	r
rrr
�twisted.python.filepathr�twisted.trial.unittestr�platformr��environ�PRECOMMIT_CI_ENVIRON�GENERIC_CI_ENVIRONrr.r1r6r8rYr�r�r�r�r�r�r'r"r �<module>r�s�����	�
�
���"�
�
�
�-�+��<�<�7���D�7�D�5��J�J�v����/��J�J�v����%���h���<	�	�;O�;O�|Q
�*�Q
�h'1�*�'1�T(
��(
�VS3�/�S3�l!J�&�(?�!J�HQ�%<�Q�2	?�x�	?r"
Page Not Found
Parece que el enlace que apuntaba aquí no sirve. ¿Quieres probar con una búsqueda?
¡Hola!